import {
    createRoleService,
	deleteRoleService,
	getRoleListService,
	getRoleDetailService,
	updateRoleService,
	getItemsService
} from "@/services/admin/role";
import express from "express";

const router = express.Router();

router.get("/", (req, res) => {
	/*
		#swagger.tags = ['管理端角色']
		#swagger.path = '/admin-api/role'
		#swagger.description = '获取角色分页数据'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.parameters['page'] = { in: 'query', description: '页号', type: 'integer' }
		#swagger.parameters['pageSize'] = { in: 'query', description: '每页个数', type: 'integer' }
		#swagger.parameters['name'] = { in: 'query', description: '角色名', type: 'string' }
		#swagger.parameters['key'] = { in: 'query', description: '角色标识', type: 'string' }
	*/
	getRoleListService(req, res);
});
router.get("/:_id", (req, res) => {
	/*
		#swagger.tags = ['管理端角色']
		#swagger.path = '/admin-api/role/{_id}'
		#swagger.description = '获取指定角色'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.parameters['_id'] = { in: 'path', description: '角色ID', type: 'string', required: true }
	*/
	getRoleDetailService(req, res);
});
router.get("/items", (req, res) => {
	/*
		#swagger.tags = ['管理端角色']
		#swagger.path = '/admin-api/role/items'
		#swagger.description = '父查子分页'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.parameters['page'] = { in: 'query', description: '页号', type: 'integer' }
		#swagger.parameters['pageSize'] = { in: 'query', description: '每页个数', type: 'integer' }
		#swagger.parameters['name'] = { in: 'query', description: '角色名', type: 'string' }
		#swagger.parameters['key'] = { in: 'query', description: '角色标识', type: 'string' }
	*/
	getItemsService(req, res);
});
router.post("/", (req, res) => {
	/*
		#swagger.tags = ['管理端角色']
		#swagger.path = '/admin-api/role'
		#swagger.description = '创建角色'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.requestBody = {
			required: true,
			content: {
				"application/json": {
					schema: {
						type: "object",
						required: ['name','key'],
						properties: {
							name: { description: '角色名', type: 'string' },
							status: { description: '角色状态', type: 'boolean' },
							permissions: { description: '权限', type: 'array', items: { type: 'string' } },
							desc: { description: '描述', type: 'string' },
							key: { description: '角色标识', type: 'string' }
						}
					}
				}
			}
		}
	*/
	createRoleService(req, res);
});
router.put("/", (req, res) => {
	/*
		#swagger.tags = ['管理端角色']
		#swagger.path = '/admin-api/role'
		#swagger.description = '更新角色'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.requestBody = {
			required: true,
			content: {
				"application/json": {
					schema: {
						type: "object",
						required: ['_id'],
						properties: {
							_id: { description: '角色ID', type: 'string' },
							name: { description: '角色名', type: 'string' },
							status: { description: '角色状态', type: 'boolean' },
							permissions: { description: '权限', type: 'array', items: { type: 'string' } },
							desc: { description: '描述', type: 'string' },
							key: { description: '角色标识', type: 'string' }
						}
					}
				}
			}
		}
	*/
	updateRoleService(req, res);
});
router.delete("/", (req, res) => {
	/*
		#swagger.tags = ['管理端角色']
		#swagger.path = '/admin-api/role'
		#swagger.description = '删除角色'
		#swagger.security = [{"bearerAuth": []}]
		#swagger.requestBody = {
			required: true,
			content: {
				"application/json": {
					schema: {
						type: "object",
						required: ['_id'],
						properties: {
							_id: { description: '角色ID', type: 'string' },
						}
					}
				}
			}
		}
	*/
	deleteRoleService(req, res);
});

export default router;